public class QuadraticEquation {
    private double a;
    private double b;
    private double c;

    public QuadraticEquation(double a, double b, double c)
    {
        this.a = a;
        this.b = b;
        this.c = c;
    }
    
    private double calculateDiscriminant()
    {
        return b * b - 4 * a * c;
    }

    public String solve() {
        double discriminant = calculateDiscriminant();

        if (discriminant > 0)
        {
            double root1 = (-b + Math.sqrt(discriminant)) / (2 * a);
            double root2 = (-b - Math.sqrt(discriminant)) / (2 * a);
            return "方程有两个不同的实根: " + root1 + " 和 " + root2;
        }
        else if (discriminant == 0)
        {
            double root = -b / (2 * a);
            return "方程有一个实根: " + root;
        }
        else
        {
            double realPart = -b / (2 * a);
            double imaginaryPart = Math.sqrt(-discriminant) / (2 * a);
            return "方程有两个共轭复根: " + realPart + " + " + imaginaryPart + "i 和 " + realPart + " - " + imaginaryPart + "i";
        }
    }

    public static void main(String[] args)
    {
        QuadraticEquation equation = new QuadraticEquation(1, -4, 4);
        System.out.println(equation.solve());
    }
}